#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
int main()
{
    int id = fork();
    if(id == 0)
    {
        printf("I am child process,pid:%d ppid:%d\n",getpid(),getppid());
        sleep(5);
        return 0;
    }
    //parent
    int count = 3;
    while(count --)
    {
        printf("I am father\n");
        sleep(2);
    }
    int status = 0;
    waitpid(id,&status,-1);
    printf("exid code:%d signal:%d codedump:%d\n",(status >> 8)&0xff,status&0x7f,(status>>7)&1);
    return 0;
}